function onBridgeReady() {
	if (WeixinJSBridge) {
		WeixinJSBridge.call('hideOptionMenu');
	}
}

if (typeof WeixinJSBridge == "undefined") {
	if (document.addEventListener) {
		document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
	} else if (document.attachEvent) {
		document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
		document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
	}
} else {
	onBridgeReady();
}

var Binding = {
	config : {},
	file : [],
	area : 0,
	order_type : 0,
	init : function(config) {
		var _this = this;
		$.extend(_this.config, config);
		_this.init_btn();
	},
	init_btn : function() {
		var _this = this;
		$("#binding").on("click", function() {
			if (validform($('#binding_form'))) {
				var data = $('#binding_form').serializeObject();
				data["openid"] = _this.config.openid;
				data["merid"] = _this.config.merid;
				$.post(_this.config.set_binding, data, function(_dat) {
					if (_dat.status) {
						tips("绑定成功！", function() {
							if (WeixinJSBridge) {
								WeixinJSBridge.invoke('closeWindow');
							} else {
								window.close();
							}
						});
					} else {
						tips(_dat.info);
					}
				});
			}
		});
	}
}
